#include <iostream>
using namespace std;
int dxdy[][4] = {
    {0, 0, 1, -1},
    {1, -1, 0, 0}
};
constexpr int MAXN = 101;
char garden[MAXN][MAXN];
int H, W;
void solve();
int main() {
    while (cin >> H >> W && W + H != 0 ) {
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++) 
                cin >> garden[i][j];
        
        solve();
    }
}


bool is_fruit(int h, int w) {
    char x = garden[h][w];
    return x == '@' || x == '#' || x == '*';
}

void dfs(int x, int y, char type) {
    for (int i = 0; i < 4; i++) {
        int nx = x + dxdy[0][i];
        int ny = y + dxdy[1][i];
        if (garden[nx][ny] == type) {
            garden[nx][ny] = '-';
            dfs(nx, ny, type);
        }
    }
}

void solve() {
    int sum = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (is_fruit(i, j)) {
                sum++;
                char t = garden[i][j];
                garden[i][j] = '-';
                dfs(i, j, t);
            }
        }
    }
    cout << sum << endl;
}